﻿using Exerciese.Model.model;
using Exercise.IIservice.Model;
using Exercise.MVC.Attrbute;
using ExerciseService;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Exercise.MVC.Controllers
{
    //[AllowAnonymous]
    //[CustomerAuthorizeAttribute]
    public class CustomerController : Controller
    {
        // http 请求解析  
        // 超文本传输协议
        // 请求 - 应答式，  

        private IUserService userService;
        private IprojectService iproject;
        public CustomerController(IUserService user, IprojectService service)
        {
            userService = user;
            iproject = service;
            //throw new Exception("");
        }

        // GET: Customer
        //[CustomerHandlerAttribute]
        //[CustomerActionFilter]
        public ActionResult Index()
        {
            //throw new Exception("");
            using (IUserService user = userService)
            {
                var list = user.Query<T_User>(x => 1 == 1).ToList();
            }


            using (IprojectService yu = iproject)
            {
                var data = yu.Set<T_Project>().ToList();
            }
            return View();
        }

        /// <summary>
        /// 异常信息
        /// </summary>
        /// <returns></returns>
        public ViewResult Exception()
        {
            return View();
        }
        

        /// <summary>
        /// json
        /// </summary>
        /// <returns></returns>
        public JsonResult JsonResult()
        {
            //Response.OutputStream.Write("");
            //var yuNa = Response.Cookies.Add("");
            return Json(new T_User()
            { }, JsonRequestBehavior.AllowGet);
        }

       
    }
}